package br.eng.megaprojetos.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import br.com.vexillum.model.annotations.SearchField;
import br.com.vexillum.model.annotations.Validate;
import br.com.vexillum.model.enums.Sexo;
import br.eng.megaprojetos.model.interfaces.IPerson;

@SuppressWarnings("serial")
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("P")
@Table(name="person")
public abstract class Person extends PersistentEntity implements IPerson {

	@SearchField
	@Validate(notNull=true)
	@Column(name="cgc", nullable=false, unique=true, updatable=false, length=20)
	private String cgc;
	
	@SearchField
	@Validate(notNull=true, min=3, max=200)
	@Column(name="name", unique=false, updatable=true, length=150)
	private String name;
	
	@Validate(notNull=true, max=8)
	@Column(name="rg", unique=false, updatable=true, length=11)
	private Long rg;
	
	@Validate(notNull=true)
	@Column(name="sex", unique=false, updatable=true)
	@Enumerated(EnumType.ORDINAL)
	private Sexo sex;
	
	@Validate(notNull=true)
	@Column(name="birth_date", unique=false, updatable=true)
	private Date birthDate;
	
	@Validate(notNull=true, max=10)
	@Column(name="cep", nullable=false, unique=false, updatable=true, length=20)
	private String cep;
	
	@Validate(notNull=true, max=1000)
	@Column(name="street", nullable=false, unique=false, updatable=true, length=500)
	private String street;
	
	@Validate(max=200)
	@Column(name="complement", nullable=true, unique=false, updatable=true, length=100)
	private String complement;
	
	@SearchField
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="id_state", nullable=false, updatable=true)
	@Validate(notNull=true)
	private State state;
	
	@Validate(max=200)
	@Column(name="neighborhood", nullable=false, unique=false, updatable=true, length=100)
	private String neighborhood;
	
	@Validate(max=200)
	@Column(name="city", nullable=false, unique=false, updatable=true, length=100)
	private String city;
	
	@Validate(max=50)
	@Column(name="phone", nullable=false, unique=false, updatable=true, length=100)
	private String phone;
	
	@Validate(max=50)
	@Column(name="cel", nullable=false, unique=false, updatable=true, length=100)
	private String cel;
	
	@Validate(max=50)
	@Column(name="email", nullable=false, unique=false, updatable=true, length=100)
	private String email;
	
	@Validate(max=200)
	@Column(name="profession", nullable=false, unique=false, updatable=true, length=100)
	private String profession;
	
	@Validate(max=200)
	@Column(name="responsible", nullable=false, unique=false, updatable=true, length=100)
	private String responsible;
	
	public String getCgc() {
		return cgc;
	}

	public void setCgc(String cgc) {
		this.cgc = cgc;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getRg() {
		return rg;
	}

	public void setRg(Long rg) {
		this.rg = rg;
	}

	public Sexo getSex() {
		return sex;
	}

	public void setSex(Sexo sex) {
		this.sex = sex;
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	public String getCep() {
		return cep;
	}

	public void setCep(String cep) {
		this.cep = cep;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getComplement() {
		return complement;
	}

	public void setComplement(String complement) {
		this.complement = complement;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public String getNeighborhood() {
		return neighborhood;
	}

	public void setNeighborhood(String neighborhood) {
		this.neighborhood = neighborhood;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getCel() {
		return cel;
	}

	public void setCel(String cel) {
		this.cel = cel;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getProfession() {
		return profession;
	}

	public void setProfession(String profession) {
		this.profession = profession;
	}

	public String getResponsible() {
		return responsible;
	}

	public void setResponsible(String responsible) {
		this.responsible = responsible;
	}

}
